{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 包装 PyTorch 模型进行量化\n",
    "\n",
    "这个例子展示了 [MSC](https://discuss.tvm.apache.org/t/rfc-unity-msc-introduction-to-multi-system-compiler/15251/5) 如何运行 PTQ（Post-Training Quantization，训练后量化）、QAT（Quantization Aware Training，量化感知训练）以及带有蒸馏的 PTQ...\n",
    "\n",
    "这个例子使用了 [resnet50](https://github.com/huyvnphan/PyTorch_CIFAR10/tree/master)，请在运行示例之前下载 `pt` 文件。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import set_env"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "import torch.optim as optim\n",
    "\n",
    "from tvm.contrib.msc.pipeline import TorchWrapper\n",
    "from tvm.contrib.msc.core.tools import ToolType\n",
    "from tvm.contrib.msc.core.utils.message import MSCStage\n",
    "from _resnet import resnet50\n",
    "from utils import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "https://drive.google.com/file/d/17fmN8eQdLpq2jIMQ_X0IXDPXfI9oVWgq/view?usp=sharing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "trainloader, testloader = get_dataloaders(args.dataset, args.train_batch, args.test_batch)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "xin",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
